package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourVideoType;
import com.ruoyi.system.service.ITourVideoTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/type1")
public class TourVideoTypeController extends BaseController
{
    @Autowired
    private ITourVideoTypeService tourVideoTypeService;

    /**
     * 查询视频列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourVideoType tourVideoType)
    {
        startPage();
        List<TourVideoType> list = tourVideoTypeService.selectTourVideoTypeList(tourVideoType);
        return getDataTable(list);
    }

    /**
     * 导出视频列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:export')")
    @Log(title = "视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourVideoType tourVideoType)
    {
        List<TourVideoType> list = tourVideoTypeService.selectTourVideoTypeList(tourVideoType);
        ExcelUtil<TourVideoType> util = new ExcelUtil<TourVideoType>(TourVideoType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Long videoId)
    {
        return AjaxResult.success(tourVideoTypeService.selectTourVideoTypeById(videoId));
    }

    /**
     * 新增视频
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:add')")
    @Log(title = "视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourVideoType tourVideoType)
    {
        return toAjax(tourVideoTypeService.insertTourVideoType(tourVideoType));
    }

    /**
     * 修改视频
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:edit')")
    @Log(title = "视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourVideoType tourVideoType)
    {
        return toAjax(tourVideoTypeService.updateTourVideoType(tourVideoType));
    }

    /**
     * 删除视频
     */
    @PreAuthorize("@ss.hasPermi('Tour:type:remove')")
    @Log(title = "视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(tourVideoTypeService.deleteTourVideoTypeByIds(videoIds));
    }
}
